#!/bin/bash
clear

# INFO='\033[97;44m'
# WARNING='\033[97;43m'
# GREEN='\033[92m'
# YELLOW='\033[93m'
TEXT='\033[30;107;2m'
SUCCESS='\033[97;42m'
ERROR='\033[97;41m'
RESET='\033[0m'

if [ "${EUID}" -ne 0 ]; then
  echo -e "${ERROR} RALAT ${RESET}${TEXT} Anda tiada kebenaran untuk menjalankan skrip ini! ${RESET}"
  exit 1
fi

clear
echo
echo -e "${TEXT} ========================================================== ${RESET}"
echo -e "${TEXT} WIREGUARD - SENARAI AKAUN PENGGUNA                         ${RESET}"
echo -e "${TEXT} ---------------------------------------------------------- ${RESET}"
echo

# clientLists=$(cat /etc/wireguard/clients/.accounts | awk '{print $1,$2,$3}')
# totalClients=$(cat /etc/wireguard/clients/.accounts | wc -l)

while read file; do
  client_lists="$(echo $file | awk '{print $1}')"
  active_duration="$(echo $file | awk '{print $2}')"
  expired_date="$(echo $file | awk '{print $3}')"
done </etc/wireguard/clients/.accounts
total_clients=$(cat /etc/wireguard/clients/.accounts | wc -l)

echo -e "${SUCCESS} JUMLAH ${RESET}${TEXT} $total_clients pengguna ${RESET}"

echo
echo -e "${TEXT} ---------------------------------------------------------- ${RESET}"
echo -e "${TEXT} Dicipta oleh Doctype, Dikuasakan oleh Cybertize.           ${RESET}"
echo -e "${TEXT} ========================================================== ${RESET}"
echo
